package com.ele.ui;

import java.util.Scanner;

import com.ele.pojo.Shop;
import com.ele.service.ShopService;

public class ShopUI {
	private static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		System.out.println("================");
		System.out.println("\t商家登录");
		System.out.println("================");
		login(); 	
	}
	/**
	 * 	商家登入界面
	 */
	private static void login() {
		System.out.println("请输入账号：");
		String id = sc.next();
		System.out.println("请输入密码：");
		String password = sc.next();
		ShopService shopService = new ShopService();
		Shop shop = shopService.shopLogin(Integer.parseInt(id),password);
		if (shop==null) {
			System.out.println("账号或密码不正确");
			login();
		}else {
			storeInterface(shop);
		}
	}
	/**
	 * 	商铺界面
	 * @param shop
	 */
	public static void storeInterface(Shop shop) {
		System.out.println("=======================================================");
		System.out.println("1.修改店铺信息"+" 2.维护菜品信息 "+"3.查看店铺信息" +" 4.退出登录");
		System.out.println("=======================================================");
		Integer input = sc.nextInt();
		ShopManager shopManager = new ShopManager();
		if (input == 1) {
			shopManager.updateShop(shop);
		}else if (input == 2) {
			shopManager.foodManager(shop);
		}else if (input == 3) {
			shopManager.shopInform(shop);
		}else if (input == 4) {
			System.out.println("是否退出？y/n");
			if (sc.nextLine().equalsIgnoreCase("y")) {
				return;
			}
		}else {
			System.out.println("输入不正确");
		}
		storeInterface(shop);
	}
}

